<template>
    <div class="container">
      <div id="teacherTop">
        <div>
          <img :src="teacher.avatar" width="200">

        </div>
        <div class="right">
          <p>

            <b>{{teacher.name}}</b>
            <b>{{teacher.level==1?'高级讲师':'首席讲师'}}</b>
          </p>
          <p>{{teacher.career}}</p>
          <p>{{teacher.intro}}</p>
        </div>
      </div>
      <h2>主讲课程</h2>
      <hr/>
      <div id="courseList">
        <ul>
          <li v-for="course in courseList">
            <a :href="'http://localhost:8080/#/courseDetail/'+course.id"><img :src="course.cover" style="width: 250px;height: 100px"></a>
            <a :href="'http://localhost:8080/#/courseDetail/'+course.id"><p>{{course.title}}</p></a>
          </li>
        </ul>
      </div>
    </div>
</template>

<script>
  import teacher from '@/api/teacher'

    export default {
        name: "teacherDetail",
      data(){
          return{
            teacher:{},//讲师信息
            courseList:[]//讲师所讲课程
          }
      },
      created() {
        this.showInfo()
      },
      methods:{
          showInfo(){
            teacher.getById(this.$route.params.id)
              .then(response=>{
                this.teacher = response.data.teacher
                this.courseList = response.data.listCourse
                console.log(response.data)
              })
          }

      }
    }
</script>

<style scoped>
#teacherTop div{
  display: inline-block;
  border: 1px solid;
  overflow: hidden;
}
#teacherTop .right{
  width: 800px;
  height: 200px;
}
  #courseList li{
    display: inline-block;
    margin-right: 15px;
    text-align: center;
  }
</style>
